<script>
    //获取验证码
    function sms3(){

        var tel = $("#tel3").val();
        if(!(/^1[34578]\d{9}$/.test(tel))){
            layer.msg("手机号码有误，请重填");
            return false;
        }
        $.ajax({
            type:'POST',
            url:"__APP__/Api/Message/TelLoginCode.html",
            data:{

                "tel": tel,

            },
            success:function(data){
                var info = eval(data)
                if (info.errcode == 0) {

                    layer.msg(info.errmsg);
                    // alert('请求成功');

                }else{
                    layer.msg(info.errmsg);
                    // alert('请求失败');
                }
            },
            error:function(){
                layer.msg('系统繁忙,请稍候重试！');
            }

        });
    }
    //获取验证码
    function sms2(){

        var tel = $("#tel2").val();
        if(!(/^1[34578]\d{9}$/.test(tel))){
            layer.msg("手机号码有误，请重填");
            return false;
        }
        $.ajax({
            type:'POST',
            url:"__APP__/Api/Message/TelLoginCode.html",
            data:{

                "tel": tel,

            },
            success:function(data){
                var info = eval(data)
                if (info.errcode == 0) {

                    layer.msg(info.errmsg);
                    // alert('请求成功');

                }else{
                    layer.msg(info.errmsg);
                    // alert('请求失败');
                }
            },
            error:function(){
                layer.msg('系统繁忙,请稍候重试！');
            }

        });
    }
    //获取验证码
    function sms1(){

        var tel = $("#tel1").val();
        if(!(/^1[34578]\d{9}$/.test(tel))){
            layer.msg("手机号码有误，请重填");
            return false;
        }
        $.ajax({
            type:'POST',
            url:"__APP__/Api/Message/TelLoginCode.html",
            data:{

                "tel": tel,

            },
            success:function(data){
                var info = eval(data)
                if (info.errcode == 0) {

                    layer.msg(info.errmsg);
                    // alert('请求成功');

                }else{
                    layer.msg(info.errmsg);
                    // alert('请求失败');
                }
            },
            error:function(){
                layer.msg('系统繁忙,请稍候重试！');
            }

        });
    }
    //注册
    function register(){

        var tel = $("#tel3").val();
        var yzm = $("#yzm3").val();
        var password = $("#password3").val();
        var repassword = $("#repassword3").val();

        if(!(/^1[34578]\d{9}$/.test(tel))){
            layer.msg("手机号码有误，请重填");
            return false;
        }
        if(yzm==''){
            layer.msg("验证码不能为空");
            return false;
        }
        if(password==''){
            layer.msg("密码不能为空");
            return false;
        }
        if(repassword==''){
            layer.msg("确认密码不能为空");
            return false;
        }
        if(repassword!=password){
            layer.msg("确认密码和密码必须相同");
            return false;
        }

        $.ajax({
            type:'POST',
            url:"__APP__/Front/Index/register.html",
            data:{

                "username": tel,
                "tel": tel,
                "code": yzm,
                "password": password,
            },
            success:function(data){
                var info = eval(data)
                if (info.errcode == 0) {

                    layer.msg(info.errmsg);
                    setTimeout(window.location.reload(),3000);

                }else{
                    layer.msg(info.errmsg);
                }
            },
            error:function(){
                layer.msg('系统繁忙,请稍候重试！');
            }

        });
    }
    //登录
    function login(){

        var tel = $("#tel2").val();
        var yzm = $("#yzm2").val();
        // var password = $("#password").val();
        // var repassword = $("#repassword").val();
        if(!(/^1[34578]\d{9}$/.test(tel))){
            layer.msg("手机号码有误，请重填");
            return false;
        }
        if(yzm==''){
            layer.msg("验证码不能为空");
            return false;
        }
        // if(password==''){
        //     layer.msg("密码不能为空");
        //     return false;
        // }
        // if(repassword==''){
        //     layer.msg("确认密码不能为空");
        //     return false;
        // }
        // if(repassword!=password){
        //     layer.msg("确认密码和密码必须相同");
        //     return false;
        // }

        $.ajax({
            type:'POST',
            url:"__APP__/Front/Index/login.html",
            data:{

                "username": tel,
                "tel": tel,
                "code": yzm,

            },
            success:function(data){
                var info = eval(data)
                if (info.errcode == 0) {

                    layer.msg(info.errmsg);
                    setTimeout(window.location.reload(),3000);

                }else{
                    layer.msg(info.errmsg);
                }
            },
            error:function(){
                layer.msg('系统繁忙,请稍候重试！');
            }

        });
    }
    //修改密码
    function modify(){

        var tel = $("#tel1").val();
        var yzm = $("#yzm1").val();
        var password = $("#password1").val();
        var repassword = $("#repassword1").val();
        if(!(/^1[34578]\d{9}$/.test(tel))){
            layer.msg("手机号码有误，请重填");
            return false;
        }
        if(yzm==''){
            layer.msg("验证码不能为空");
            return false;
        }
        if(password==''){
            layer.msg("密码不能为空");
            return false;
        }
        if(repassword==''){
            layer.msg("确认密码不能为空");
            return false;
        }
        if(repassword!=password){
            layer.msg("确认密码和密码必须相同");
            return false;
        }

        $.ajax({
            type:'POST',
            url:"__APP__/Front/Index/modify.html",
            data:{
                "username": tel,
                "tel": tel,
                "code": yzm,
                "password": password,
            },
            success:function(data){
                var info = eval(data)
                if (info.errcode == 0) {

                    layer.msg(info.errmsg);
                    setTimeout(window.location.reload(),3000);

                }else{
                    layer.msg(info.errmsg);
                }
            },
            error:function(){
                layer.msg('系统繁忙,请稍候重试！');
            }

        });
    }
</script>